package com.org.forex;

import java.awt.EventQueue;

import javax.swing.JFrame;
import java.awt.GridLayout;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.Choice;
import javax.swing.JButton;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class StatisticForm {

	private JFrame frmStatisticControlPanel;
	private JLabel lblOffsetSample;
	private JTextField txt_offset_sample;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					StatisticForm window = new StatisticForm();
					window.frmStatisticControlPanel.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public StatisticForm() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frmStatisticControlPanel = new JFrame();
		frmStatisticControlPanel.setTitle("Statistic Control Panel");
		frmStatisticControlPanel.setResizable(false);
		frmStatisticControlPanel.setBounds(100, 100, 450, 300);
		frmStatisticControlPanel.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frmStatisticControlPanel.getContentPane().setLayout(null);

		lblOffsetSample = new JLabel("offset sample");
		lblOffsetSample.setBounds(10, 11, 115, 14);
		frmStatisticControlPanel.getContentPane().add(lblOffsetSample);

		txt_offset_sample = new JTextField();
		txt_offset_sample.setText("100");
		txt_offset_sample.setBounds(130, 8, 86, 20);
		frmStatisticControlPanel.getContentPane().add(txt_offset_sample);
		txt_offset_sample.setColumns(10);

		JLabel lblMatchSample = new JLabel("match sample");
		lblMatchSample.setBounds(10, 36, 78, 14);
		frmStatisticControlPanel.getContentPane().add(lblMatchSample);

		final Choice choiceMatchSample = new Choice();
		choiceMatchSample.setBounds(130, 30, 86, 20);
		choiceMatchSample.add("0");
		choiceMatchSample.add("1");
		choiceMatchSample.add("2");
		choiceMatchSample.add("3");
		choiceMatchSample.add("4");
		choiceMatchSample.add("5");
		choiceMatchSample.add("6");
		choiceMatchSample.add("7");
		choiceMatchSample.add("8");
		choiceMatchSample.add("9");
		frmStatisticControlPanel.getContentPane().add(choiceMatchSample);

		JButton btnShow = new JButton("Show");
		btnShow.addMouseListener(new MouseAdapter() {
			@Override
			public void mousePressed(MouseEvent arg0) {
				Statistic.setOffset_sample(Integer.parseInt(txt_offset_sample
						.getText()));
				Statistic.setIndex(choiceMatchSample.getSelectedIndex());
				Statistic.setTitle("Offset sample"
						+ txt_offset_sample.getText() + "    Match num : "
						+ choiceMatchSample.getSelectedIndex());
				Statistic.show();
			}
		});
		btnShow.setBounds(335, 228, 89, 23);
		frmStatisticControlPanel.getContentPane().add(btnShow);
	}
}
